package tests;

import junit.framework.TestCase;
import lib.*;


public class TestRectangleArea extends TestCase {

	/**
	 * Tests that the correct exception is thrown for invalid constructor args
	 */
	public void testConstructorExceptions() {
		RectangleArea rectangle;
		CartesianPoint lowLeft;
		CartesianPoint upRight;
		
		// upRight has a lower x value than lowLeft
		lowLeft = new CartesianPoint(1,0);
		upRight = new CartesianPoint(-1,1);
		try {
			rectangle = new RectangleArea(lowLeft, upRight);
			fail("Exception not thrown");
		} catch (Exception e) {
			assertEquals("Incorrect Exception Thrown", IllegalArgumentException.class, e.getClass());
		}

		// upRight has a lower y value than lowLeft
		lowLeft = new CartesianPoint(-2,1);
		upRight = new CartesianPoint(1,-1);
		try {
			rectangle = new RectangleArea(lowLeft, upRight);
			fail("Exception not thrown");
		} catch (Exception e) {
			assertEquals("Incorrect Exception Thrown", IllegalArgumentException.class, e.getClass());
		}
	}
	
}
